const path = require('path')
const fs = require('fs')
class HomeCtl {
  index(ctx) {
    const html = fs.readFileSync("app/public/html/index.html", 'utf8');
    ctx.body = html
  }
  upload(ctx) {
    const file = ctx.request.files.file
    const basename = path.basename(file.filepath)
    ctx.body = {
      url: `${ctx.origin}/upload/${basename}`
    }
  }
}
module.exports = new HomeCtl();